import React from "react";

class App extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      number: 0,
    };
  }

  handleChange = () => {
    this.setState(() => {
      return {
        // 返回 0,1,2 这三个随机数
        number: Math.floor(Math.random() * 3),
      };
    });
  };

  render() {
    const el = (
      <div>
        <h1>随机数：</h1>
        <p>{this.state.number}</p>
        <button onClick={this.handleChange}>重新生成</button>
      </div>
    )
    console.log(el)
    return el
  }


}

export default App;
